<template>
  <div class="container evaluationContainer">
    <el-dialog
      :title="title"
      :visible.sync ="state"
      :isShow="isShow"
      :before-close="handleClose"
      width="532px">
      <el-form   :model="companyData" :rules="choiseCompany" ref="choiseCompany">
        <ul>
          <el-form-item prop="selectCompany" >
            <li v-for="(item,index ) in evaluationList">
              <el-radio v-model="companyData.selectCompany"  :label="item.evaplan_type_id">{{item.evaplan_type_name}}</el-radio>
            </li>
          </el-form-item>
        </ul>
      </el-form>
      <!--<el-row v-for="(item,index) in evaluationList" :key="index"  style="margin-bottom:16px;">-->
        <!--<el-col :span="2" style="text-align: center">-->
          <!--<el-checkbox v-model="item.checked"></el-checkbox>-->
        <!--</el-col>-->
        <!--<el-col :span="20">-->
          <!--{{item.evaplan_type_name}}-->
        <!--</el-col>-->
      <!--</el-row>-->
      <span slot="footer" class="dialog-footer">
        <el-button type="primary"  size="small" @click.native="selectEvaluation('choiseCompany')"   >确 定</el-button>
      </span>
    </el-dialog>
    <!--<span @click="selectEvaluation">确 定</span>-->
  </div>
</template>

<script>
  export default {
    name: "evaluationList",
    props: {
      isShow: {
        type: Boolean,
        default:true
      },
      title: {
        type: String,
        default: "请选择需要审核的报告"
      },
      evaluationList:{
        type:Array
      }
    },
    computed:{

    },
    watch:{
      state(val){
        this.$emit('update:select-evaluation-state', 'hello');
      }
    },
    data(){
      var checkcompanyName =(rule, value, callback) => {
        if(value==undefined ||value==''){
          return callback('请选择报告')
        }else{
          callback()
        }
      };
      return {
        dialogVisible: false,
        state:true,
        companyData:{},
        //选择评价公司验证
        choiseCompany:
          {
            selectCompany:[
              { required: true,validator:checkcompanyName}
            ]
          },
      }
    },
    methods:{
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            this.$router.go(-1);
//            this.$alert("请先选择评价报告",'提示',{
//              confirmButtonText: '确定',
//              callback: action => {
//                this.$router.go(-1)
//              }
//            });
          })
          .catch(_ => {});
      },
      selectEvaluation(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.state = false
            this.checkCompany=this.companyData.selectCompany;
            this.companyForm =false;
            this.$emit('selectReport',this.checkCompany)
            console.log();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
        // this.$emit('update:selectEvaluationState', 'hello');
      },
      changeStatus(){
        this.$alert("请先选择评价类型",'提示',{
          confirmButtonText: '确定',
          callback: action => {
            this.$router.go(-1)
          }
        });
//        this.$emit('close')
      }


    }
  }
</script>

<style scoped>
 .container>>> .el-dialog__title{
    font-size:16px;
  }
  .container>>> .el-dialog__body{
    padding-top:12px;
  }
 .container >>> .el-dialog .el-form ul{
   height: 360px;
   overflow-y: scroll;
 }
</style>
